package com.opal.modules.costReportForm.controller;

import com.opal.modules.costReportForm.entity.table.CartonCompanyDetailsWithBLOBs;
import com.opal.modules.costReportForm.entity.table.CartonPriceDetails;
import com.opal.modules.costReportForm.model.CartonData;
import com.opal.modules.costReportForm.model.CartonPriceDetailsRecord;
import com.opal.modules.costReportForm.service.CartonDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 纸箱
 */
@RequestMapping("costReportCarton")
@RestController
public class CartonDetailsController {
    @Autowired
    private CartonDetailsService cartonDetailsService;

    /**
     * 根据条件获取纸箱单价easyui的表格数据
     * @param cartonData
     * @return
     */
    @RequestMapping("getAllCartonDetails")
    public Object onConditiongetCartonDetails(CartonData cartonData){
        return cartonDetailsService.onConditiongetCartonDetailsService(cartonData);
    }


    /**
     * 根据条件获取easyui的表格数据
     * @param cartonPriceDetailsRecord
     * @return
     */
    @RequestMapping("getCartonPriceDetailsRecord")
    public Object getCartonPriceDetailsRecordByTAndcostReportId(CartonPriceDetailsRecord cartonPriceDetailsRecord){
        return cartonDetailsService.getCartonPriceDetailsRecordByTAndcostReportIdService(cartonPriceDetailsRecord);
    }

    /**
     * 为easyui的combobox组件获取所有的公司名称
     * @return
     */
    @RequestMapping("getCartonCompany")
    public Object getCartonCompany(){
        return cartonDetailsService.getCartonCompanyService();
    }

    /**
     * 根据公司主键id为datagrid获取数据
     * @param id
     * @return
     */
    @RequestMapping("getCartonCompanyAndPrice")
    public Object getCartonCompanyAndPrice(Long id){
        return cartonDetailsService.getCartonCompanyAndPriceService(id);
    }

    /**
     * 根据公司姓名为combobox组件获取公司信息
     * @companyName 公司名称
     * @return
     */
    @RequestMapping("getCartonCompanyCompanyName")
    public Object getCartonCompanyCompanyName(String companyName){
        return cartonDetailsService.getCartonCompanyCompanyNameService(companyName);
    }

    /**
     * 通过公司姓名和公司报价单号查询相应的数据
     * @param quotationCode
     * @param quotationCode
     * @return
     */
    @RequestMapping("getCartonCompanyByNameAndCode")
    public Object getCartonCompanyByNameAndCode(String companyName,String quotationCode){
        return cartonDetailsService.getCartonCompanyByNameAndCodeService(companyName,quotationCode);
    }
    /**
     * 添加公司信息
     * @param companyDetailsWithBLOBs
     * @return
     */
    @RequestMapping("addCartonCompanyInfo")
    public Object addCartonCompanyInfo(CartonCompanyDetailsWithBLOBs companyDetailsWithBLOBs){
        return cartonDetailsService.addCartonCompanyInfoService(companyDetailsWithBLOBs);
    }

    /**
     * 添加公司信息
     * @param companyDetailsWithBLOBs
     * @return
     */
    @RequestMapping("updateCartonCompanyInfo")
    public Object updateCartonCompanyInfo(CartonCompanyDetailsWithBLOBs companyDetailsWithBLOBs){
        return cartonDetailsService.updateCartonCompanyInfoService(companyDetailsWithBLOBs);
    }

    /**
     * 根据id删除公司信息及数据
     * @param id
     * @return
     */
    @RequestMapping("deleteCartonCompanyInfo")
    public Object addCartonCompanyInfo(Long id){
        return cartonDetailsService.deleteCartonCompanyInfoService(id);
    }

    /**
     * 保存公司纸箱单价数据
     * @param cartonPriceDetails 纸箱单价bean
     * @return
     */
    @RequestMapping("saveCartonPrice")
    public Object saveCartonPrice(CartonPriceDetails cartonPriceDetails){
        return cartonDetailsService.saveCartonPriceService(cartonPriceDetails);
    }

    /**
     * 修改公司纸箱单价数据
     * @param cartonPriceDetails 纸箱单价bean
     * @return
     */
    @RequestMapping("updateCartonPrice")
    public Object updateCartonPrice(CartonPriceDetails cartonPriceDetails){
        return cartonDetailsService.updateCartonPriceService(cartonPriceDetails);
    }

    /**
     * 根据id删除公司纸箱单价数据
     * @param id 纸箱单价主键id
     * @return
     */
    @RequestMapping("deleteCartonPrice")
    public Object deleteCartonPrice(Long id){
        return cartonDetailsService.deleteCartonPriceService(id);
    }
}
